<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
		<title>Forager Site</title>
		<link href="${resource(dir:	'css', file:'forager.css')}" type="text/css" rel="stylesheet">
		<g:javascript library="jquery"/>		
		<r:layoutResources />
		
<script type="text/javascript">
	var refreshCall = true
	var t
	var r
	
	function loading(){
		if(${check}==false){
			
			document.getElementById('start_stop').style.visibility = 'hidden';
		}
	}
	function ClickMe(){
			if(refreshCall==true){
				Refresh()
				refreshCall=false
			}
			
			//document.getElementById("auto").click();
	        r = setTimeout('document.getElementById("stop_start").click()',2000);
	     
	 		
	 }


	function ClickHere(){

        
		var dom = document.getElementById("start_stop");
        dom.setAttribute("style","visibility:hidden");
        
		ClickMe();
		
		
        
     
 		
 }


function Stop(){
		
	clearTimeout(t);
	clearTimeout(r);

	var dom = document.getElementById("start_stop");

    dom.setAttribute("style","visibility:visible");
    
 }

function Refresh(){
	t = setInterval(function(){<g:remoteFunction controller="Forager" action="statusControl" update="displayStatus"/>},1000);
}

function kill(){

	clearTimeout(t);
	clearTimeout(r);
	var dom = document.getElementById("start_stop");

    dom.setAttribute("style","visibility:visible");

    var dom2 = document.getElementById("results");
    dom.setAttribute("style","border-color: black");
	
}
	
</script>
		
		
</head>

<body onload="loading()">
<r:layoutResources />
	
	<header>
	
	
	<div class="login">
		<nav class="menu">
			<ul>
				<li><a href="#">About us</a></li>
			</ul>
		</nav>
	</div>
	
	<div class="site">
		<div class="logo"><img src="${resource(dir: 'images', file:'logo.jpg') }" alt="logo" width="400" height="220"/></div>
		<div class="website"><h1>Forager Project</h1></div>
	</div>
	
	
	</header>
	
	
	
	
	<section class="articles">
		
		
		<div class="content_2">
		
		<div id="form_2">
			
			
		
			
				<table id="buttons">
				
					<tr><td><g:form><g:actionSubmit id="start_stop" action="forage" value="Start" onClick="ClickHere()"/></g:form></td>
						
						<td></td><td><g:formRemote url="[controller:'Forager', action:'extract']"  update="display" name="Form" onComplete="ClickMe()">

						<input id="stop_start" type="submit" value="Status"/>

						</g:formRemote>	
						<td>
						<g:formRemote url="[controller:'Forager', action:'archive']" update="display" name="NewFormArchive" onComplete="kill()">

						<div> <input id="archive" type="submit" value="Archive"/></div>

						</g:formRemote>		

						</td>
							
			
					    
						<td>
						<g:formRemote url="[controller:'Forager', action:'stop']" name="NewForm" onComplete="Stop()">

						<div> <input id="stop" type="submit" value="Stop"/></div>

						</g:formRemote>	

						</td>
					    
					   <g:form><td></td><td><g:actionSubmit class="login_forager" action="logout" value="Log out"/></td></g:form><td></td>
					    
				  </tr>
				  
				</table>
			
				
		<div id="displayStatus"></div>
				
				<div id="display">
				
					
				
					
				</div>
			
		</div>
		
		
		</div>
		
		
	</section>
		

	
	



	</body>

</html>